package timewheel

import (
	"time"
)

var tw = MakeTimeWheel(time.Second, 3600)

func init() {
	tw.Start()
}

// Delay 延迟执行某个任务
func Delay(duration time.Duration, key string, job func()) {
	tw.AddJob(duration, key, job)
}

// At 指定一个时间执行该任务
func At(at time.Time, key string, job func()) {
	tw.AddJob(at.Sub(time.Now()), key, job)
}

// Cancel 停止某个任务
func Cancel(key string) {
	tw.RemoveJob(key)
}
